package com.cwd.arm.application.service.write;

import com.cwd.arm.application.dto.confirmIncome.TargetConfirmAmountUpdateDto;
import com.cwd.arm.application.service.write.facade.TargetConfirmAmountWriteService;
import com.cwd.arm.domain.entity.TargetConfirmAmountEntity;
import com.cwd.arm.domain.repository.TargetConfirmAmountRepository;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

/**
* Description:目标确认金额
* Created on 2022年01月15日
* @author  yan
*/
@Repository
@Primary
public class TargetConfirmAmountWriteServiceImpl implements TargetConfirmAmountWriteService{

    @Autowired
    private TargetConfirmAmountRepository targetConfirmAmountRepository;

    @Override
    public void saveOrUpdate(TargetConfirmAmountUpdateDto updateDto) {
        targetConfirmAmountRepository.saveOrUpdate(convertToEntity(updateDto));
    }

    private TargetConfirmAmountEntity convertToEntity(TargetConfirmAmountUpdateDto updateDto){
        TargetConfirmAmountEntity entity = new TargetConfirmAmountEntity();
        BeanUtils.copyProperties(updateDto,entity);
        return entity;
    }
}
